const promise = new Promise((resolve, reject) => {
    setTimeout(() => {
    console.log("异步任务完成");
    resolve();
    }, 1000);
   });

// promise.then(() => {
//     console.log("Promise已消耗");
//    });

// new Promise((resolve, reject) => {
//     setTimeout(() => {
//     console.log("异步任务2完成");
//     resolve();
//     }, 1000);
//    }).then(() => {
//     console.log("Promise 2已消耗");
//    });

const getUser = new Promise((resolve, reject) => {
    const error = false;
    if (!error) {
    resolve({ name: "John", age: 30 });
    } else {
    reject("发⽣错误。");
    }
   });
   getUser.then((user) => {
    console.log(user);
   }).catch((error) => {
    console.log(error);
   }).finally(() => {
    console.log("Promise已解决或被拒绝。");
   });

console.log("来⾃全局作⽤域的输出");

